package com.feng.cloud.common.response;

import com.feng.cloud.common.exception.auth.AuthStatus;
import com.feng.cloud.common.exception.system.SystemStatus;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * @ClassName RestResponse
 * @Description TODO
 * @Author Better Feng
 * @Date 2019/12/12 15:23
 * @Version 1.0
 **/
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@NoArgsConstructor
public class RestResponse<T> extends BaseResponse {
    T data;

    public RestResponse<T> data(T data) {
        this.setData(data);
        return this;
    }

    public static <T> RestResponse<T> ok(T data) {
        RestResponse<T> response = new RestResponse<>();
        response.data(data);
        return response;
    }

    public RestResponse<T> error(String message) {
        this.setStatus(500);
        this.setMessage(message);
        return this;
    }

    public RestResponse(AuthStatus authStatus) {
        super(authStatus);
    }
    public RestResponse(SystemStatus systemStatus) {
        super(systemStatus);
    }
}
